<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改户')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-room-edit" th:object="${room}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label  class="col-sm-3 control-label ">所属社区：</label>
                <div class="col-sm-8">
                    <input disabled="disabled" class="form-control" type="text" th:field="*{sqName}" name="sqName" >
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">所属场所类型：</label>
                <div class="col-sm-8">
                    <select disabled="disabled" name="sscsLx" class="form-control m-b" th:with="type=${@dict.getType('b_zzslx')}" >
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{sscsLx}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">所属场所名称：</label>
                <div class="col-sm-8">
                    <input disabled="disabled" name="sscsMc" th:field="*{sscsMc}" class="form-control" type="text" >
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label ">楼号：</label>
                <div class="col-sm-8">
                    <input disabled="disabled" name="lh" th:field="*{lh}" class="form-control" type="text" >
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">房号：</label>
                <div class="col-sm-8">
                    <input disabled name="kjzrs" th:field="*{roomCode}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">可居住人数：</label>
                <div class="col-sm-8">
                    <input name="kjzrs" th:field="*{kjzrs}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">实际居住人数：</label>
                <div class="col-sm-8">
                    <input name="jzrs" th:field="*{jzrs}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "place/room";
        $.validator.addMethod("checkJzrs",function(value,element,params){
            //可居住人数
            var kjzrs =$("input[name=kjzrs]").val();
            if(kjzrs){
                return parseInt(kjzrs)>=parseInt($("input[name=jzrs]").val());
            }else{
                return true;
            }
        },"实际居住人数要小于等于可居住人数！");

        $("#form-room-edit").validate({
            focusCleanup: true,
            rules:{
                kjzrs:{
                    digits:true,
                    min:0,
                    max:254,
                    required:true
                },
                jzrs:{
                    digits:true,
                    min:0,
                    max:254,
                    required:true,
                    checkJzrs:true
                }
            },
            messages:{
                kjzrs:"只能输入0-254之间的正整数",
                jzrs:"只能输入0-254之间的正整数,且该数值不能大于可居住人数",
            }

        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-room-edit').serialize());
            }
        }
    </script>
</body>
</html>